{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"type\": \"FeatureCollection\",\n",
      "  \"features\": [\n",
      "    {\n",
      "      \"type\": \"Feature\",\n",
      "      \"properties\": {\n",
      "        \"fill\": true\n",
      "      },\n",
      "      \"geometry\": {\n",
      "        \"type\": \"Polygon\",\n",
      "        \"coordinates\": [\n",
      "          [\n",
      "            [\n",
      "              2.331032753,\n",
      "              48.8411359942\n",
      "            ],\n",
      "            [\n",
      "              2.3269987106,\n",
      "              48.8425764529\n",
      "            ],\n",
      "            [\n",
      "              2.3253250122,\n",
      "              48.8431130838\n",
      "            ],\n",
      "            [\n",
      "              2.3240375519,\n",
      "              48.8435367357\n",
      "            ],\n",
      "            [\n",
      "              2.3217630386,\n",
      "              48.8443840288\n",
      "            ],\n",
      "            [\n",
      "              2.3203468323,\n",
      "              48.8448923977\n",
      "            ],\n",
      "            [\n",
      "              2.3189735413,\n",
      "              48.8453160346\n",
      "            ],\n",
      "            [\n",
      "              2.3167848587,\n",
      "              48.846558682\n",
      "            ],\n",
      "            [\n",
      "              2.3136520386,\n",
      "              48.8456831836\n",
      "            ],\n",
      "            [\n",
      "              2.3111844063,\n",
      "              48.8450618529\n",
      "            ],\n",
      "            [\n",
      "              2.3070859909,\n",
      "              48.8438897762\n",
      "            ],\n",
      "            [\n",
      "              2.2969740629,\n",
      "              48.8408994443\n",
      "            ],\n",
      "            [\n",
      "              2.2952359915,\n",
      "              48.8427106112\n",
      "            ],\n",
      "            [\n",
      "              2.2949945927,\n",
      "              48.84285183\n",
      "            ],\n",
      "            [\n",
      "              2.2928863764,\n",
      "              48.8436249961\n",
      "            ],\n",
      "            [\n",
      "              2.2912180424,\n",
      "              48.844327543\n",
      "            ],\n",
      "            [\n",
      "              2.2873932123,\n",
      "              48.8458173336\n",
      "            ],\n",
      "            [\n",
      "              2.2863632441,\n",
      "              48.8462833253\n",
      "            ],\n",
      "            [\n",
      "              2.2854137421,\n",
      "              48.8467704938\n",
      "            ],\n",
      "            [\n",
      "              2.2820448875,\n",
      "              48.849008584\n",
      "            ],\n",
      "            [\n",
      "              2.2804355621,\n",
      "              48.8498063649\n",
      "            ],\n",
      "            [\n",
      "              2.2793841362,\n",
      "              48.8498204848\n",
      "            ],\n",
      "            [\n",
      "              2.2790408134,\n",
      "              48.8506535519\n",
      "            ],\n",
      "            [\n",
      "              2.2756505013,\n",
      "              48.8526585039\n",
      "            ],\n",
      "            [\n",
      "              2.2742128372,\n",
      "              48.8531667889\n",
      "            ],\n",
      "            [\n",
      "              2.2726249695,\n",
      "              48.8535197615\n",
      "            ],\n",
      "            [\n",
      "              2.2703289986,\n",
      "              48.8542539366\n",
      "            ],\n",
      "            [\n",
      "              2.2671747208,\n",
      "              48.8551434035\n",
      "            ],\n",
      "            [\n",
      "              2.2649002075,\n",
      "              48.855694018\n",
      "            ],\n",
      "            [\n",
      "              2.2637414932,\n",
      "              48.8544233601\n",
      "            ],\n",
      "            [\n",
      "              2.2617030144,\n",
      "              48.8551010483\n",
      "            ],\n",
      "            [\n",
      "              2.2633981705,\n",
      "              48.8576564152\n",
      "            ],\n",
      "            [\n",
      "              2.2649002075,\n",
      "              48.8599434285\n",
      "            ],\n",
      "            [\n",
      "              2.2664451599,\n",
      "              48.8626538275\n",
      "            ],\n",
      "            [\n",
      "              2.2666811943,\n",
      "              48.8631902432\n",
      "            ],\n",
      "            [\n",
      "              2.267947197,\n",
      "              48.8647006461\n",
      "            ],\n",
      "            [\n",
      "              2.2694063187,\n",
      "              48.8667897264\n",
      "            ],\n",
      "            [\n",
      "              2.2713589668,\n",
      "              48.8690480934\n",
      "            ],\n",
      "            [\n",
      "              2.2736120224,\n",
      "              48.871009967\n",
      "            ],\n",
      "            [\n",
      "              2.2753071785,\n",
      "              48.8723507717\n",
      "            ],\n",
      "            [\n",
      "              2.2773456573,\n",
      "              48.8737197667\n",
      "            ],\n",
      "            [\n",
      "              2.2782897949,\n",
      "              48.8750040476\n",
      "            ],\n",
      "            [\n",
      "              2.2804999352,\n",
      "              48.8774737258\n",
      "            ],\n",
      "            [\n",
      "              2.2818946838,\n",
      "              48.8795058267\n",
      "            ],\n",
      "            [\n",
      "              2.2835040092,\n",
      "              48.8808605148\n",
      "            ],\n",
      "            [\n",
      "              2.2857570648,\n",
      "              48.882229277\n",
      "            ],\n",
      "            [\n",
      "              2.2899627686,\n",
      "              48.8848396989\n",
      "            ],\n",
      "            [\n",
      "              2.2913146019,\n",
      "              48.8857568418\n",
      "            ],\n",
      "            [\n",
      "              2.294511795,\n",
      "              48.8876475141\n",
      "            ],\n",
      "            [\n",
      "              2.2955846786,\n",
      "              48.8878732613\n",
      "            ],\n",
      "            [\n",
      "              2.2964859009,\n",
      "              48.8878027154\n",
      "            ],\n",
      "            [\n",
      "              2.297065258,\n",
      "              48.8876192956\n",
      "            ],\n",
      "            [\n",
      "              2.2975587845,\n",
      "              48.8874923124\n",
      "            ],\n",
      "            [\n",
      "              2.298116684,\n",
      "              48.8875064216\n",
      "            ],\n",
      "            [\n",
      "              2.298438549,\n",
      "              48.8875910772\n",
      "            ],\n",
      "            [\n",
      "              2.2989320755,\n",
      "              48.8879296979\n",
      "            ],\n",
      "            [\n",
      "              2.2997903824,\n",
      "              48.8882965344\n",
      "            ],\n",
      "            [\n",
      "              2.3006701469,\n",
      "              48.8886210414\n",
      "            ],\n",
      "            [\n",
      "              2.3015713692,\n",
      "              48.889270049\n",
      "            ],\n",
      "            [\n",
      "              2.3037815094,\n",
      "              48.8903423041\n",
      "            ],\n",
      "            [\n",
      "              2.3057985306,\n",
      "              48.8900742425\n",
      "            ],\n",
      "            [\n",
      "              2.3074293137,\n",
      "              48.8893405928\n",
      "            ],\n",
      "            [\n",
      "              2.3093390465,\n",
      "              48.8887762396\n",
      "            ],\n",
      "            [\n",
      "              2.311205864,\n",
      "              48.8880566801\n",
      "            ],\n",
      "            [\n",
      "              2.314145565,\n",
      "              48.8876051864\n",
      "            ],\n",
      "            [\n",
      "              2.3184370995,\n",
      "              48.8917954552\n",
      "            ],\n",
      "            [\n",
      "              2.3220419884,\n",
      "              48.8897497449\n",
      "            ],\n",
      "            [\n",
      "              2.325668335,\n",
      "              48.887703951\n",
      "            ],\n",
      "            [\n",
      "              2.3268485069,\n",
      "              48.8851924481\n",
      "            ],\n",
      "            [\n",
      "              2.3274922371,\n",
      "              48.8838378774\n",
      "            ],\n",
      "            [\n",
      "              2.328063794,\n",
      "              48.883946667\n",
      "            ],\n",
      "            [\n",
      "              2.329651662,\n",
      "              48.88493438\n",
      "            ],\n",
      "            [\n",
      "              2.336046047,\n",
      "              48.88318471\n",
      "            ],\n",
      "            [\n",
      "              2.339479275,\n",
      "              48.882422738\n",
      "            ],\n",
      "            [\n",
      "              2.342912503,\n",
      "              48.882987163\n",
      "            ],\n",
      "            [\n",
      "              2.345744913,\n",
      "              48.883551581\n",
      "            ],\n",
      "            [\n",
      "              2.34951366,\n",
      "              48.884013132\n",
      "            ],\n",
      "            [\n",
      "              2.35071529,\n",
      "              48.882827858\n",
      "            ],\n",
      "            [\n",
      "              2.351959835,\n",
      "              48.881501444\n",
      "            ],\n",
      "            [\n",
      "              2.352954691,\n",
      "              48.880503646\n",
      "            ],\n",
      "            [\n",
      "              2.354234348,\n",
      "              48.8790743\n",
      "            ],\n",
      "            [\n",
      "              2.355393062,\n",
      "              48.877752921\n",
      "            ],\n",
      "            [\n",
      "              2.35625137,\n",
      "              48.876623947\n",
      "            ],\n",
      "            [\n",
      "              2.3603439331,\n",
      "              48.8759495959\n",
      "            ],\n",
      "            [\n",
      "              2.3634767532,\n",
      "              48.875413317\n",
      "            ],\n",
      "            [\n",
      "              2.3630905151,\n",
      "              48.8741996118\n",
      "            ],\n",
      "            [\n",
      "              2.3636484146,\n",
      "              48.8733528233\n",
      "            ],\n",
      "            [\n",
      "              2.3643350601,\n",
      "              48.8725060204\n",
      "            ],\n",
      "            [\n",
      "              2.3652791977,\n",
      "              48.8711511061\n",
      "            ],\n",
      "            [\n",
      "              2.3658370972,\n",
      "              48.8704171788\n",
      "            ],\n",
      "            [\n",
      "              2.3668670654,\n",
      "              48.8691468946\n",
      "            ],\n",
      "            [\n",
      "              2.3678970337,\n",
      "              48.8694432972\n",
      "            ],\n",
      "            [\n",
      "              2.3685836792,\n",
      "              48.8686105428\n",
      "            ],\n",
      "            [\n",
      "              2.368991375,\n",
      "              48.8680459556\n",
      "            ],\n",
      "            [\n",
      "              2.3677682877,\n",
      "              48.8677636597\n",
      "            ],\n",
      "            [\n",
      "              2.3687553406,\n",
      "              48.8666626902\n",
      "            ],\n",
      "            [\n",
      "              2.3702573776,\n",
      "              48.8647994559\n",
      "            ],\n",
      "            [\n",
      "              2.371544838,\n",
      "              48.8632184755\n",
      "            ],\n",
      "            [\n",
      "              2.3724031448,\n",
      "              48.8618350766\n",
      "            ],\n",
      "            [\n",
      "              2.3724031448,\n",
      "              48.8604516395\n",
      "            ],\n",
      "            [\n",
      "              2.3719739914,\n",
      "              48.8594634467\n",
      "            ],\n",
      "            [\n",
      "              2.371544838,\n",
      "              48.8586164088\n",
      "            ],\n",
      "            [\n",
      "              2.3711585999,\n",
      "              48.8575434736\n",
      "            ],\n",
      "            [\n",
      "              2.3706436157,\n",
      "              48.8566681672\n",
      "            ],\n",
      "            [\n",
      "              2.3701715469,\n",
      "              48.8555951902\n",
      "            ],\n",
      "            [\n",
      "              2.3698282242,\n",
      "              48.8546916128\n",
      "            ],\n",
      "            [\n",
      "              2.3700428009,\n",
      "              48.8529126471\n",
      "            ],\n",
      "            [\n",
      "              2.3684120178,\n",
      "              48.8526302657\n",
      "            ],\n",
      "            [\n",
      "              2.3662662506,\n",
      "              48.8520654983\n",
      "            ],\n",
      "            [\n",
      "              2.3646354675,\n",
      "              48.8515007245\n",
      "            ],\n",
      "            [\n",
      "              2.3644798994,\n",
      "              48.8514583662\n",
      "            ],\n",
      "            [\n",
      "              2.3643136024,\n",
      "              48.8514195377\n",
      "            ],\n",
      "            [\n",
      "              2.3640614748,\n",
      "              48.8513312911\n",
      "            ],\n",
      "            [\n",
      "              2.3639059067,\n",
      "              48.8512854028\n",
      "            ],\n",
      "            [\n",
      "              2.3637878895,\n",
      "              48.8512395145\n",
      "            ],\n",
      "            [\n",
      "              2.3636591434,\n",
      "              48.8511759767\n",
      "            ],\n",
      "            [\n",
      "              2.3634928465,\n",
      "              48.8511159687\n",
      "            ],\n",
      "            [\n",
      "              2.363294363,\n",
      "              48.8510594905\n",
      "            ],\n",
      "            [\n",
      "              2.3630422354,\n",
      "              48.8509888927\n",
      "            ],\n",
      "            [\n",
      "              2.3628437519,\n",
      "              48.8509394742\n",
      "            ],\n",
      "            [\n",
      "              2.3625648022,\n",
      "              48.8507806287\n",
      "            ],\n",
      "            [\n",
      "              2.3624360561,\n",
      "              48.8507100305\n",
      "            ],\n",
      "            [\n",
      "              2.3620980978,\n",
      "              48.8506641416\n",
      "            ],\n",
      "            [\n",
      "              2.3619157076,\n",
      "              48.8506394322\n",
      "            ],\n",
      "            [\n",
      "              2.3615992069,\n",
      "              48.8506217826\n",
      "            ],\n",
      "            [\n",
      "              2.361395359,\n",
      "              48.8505829535\n",
      "            ],\n",
      "            [\n",
      "              2.3611968756,\n",
      "              48.8505441243\n",
      "            ],\n",
      "            [\n",
      "              2.3611646891,\n",
      "              48.8504982353\n",
      "            ],\n",
      "            [\n",
      "              2.361100316,\n",
      "              48.8504452864\n",
      "            ],\n",
      "            [\n",
      "              2.3609608412,\n",
      "              48.8503888075\n",
      "            ],\n",
      "            [\n",
      "              2.3608535528,\n",
      "              48.8503287985\n",
      "            ],\n",
      "            [\n",
      "              2.3607730865,\n",
      "              48.8502970291\n",
      "            ],\n",
      "            [\n",
      "              2.3605155945,\n",
      "              48.8502299602\n",
      "            ],\n",
      "            [\n",
      "              2.360419035,\n",
      "              48.8501805409\n",
      "            ],\n",
      "            [\n",
      "              2.3603439331,\n",
      "              48.8501523013\n",
      "            ],\n",
      "            [\n",
      "              2.3601508141,\n",
      "              48.8500287529\n",
      "            ],\n",
      "            [\n",
      "              2.3589706421,\n",
      "              48.8495804459\n",
      "            ],\n",
      "            [\n",
      "              2.3583698273,\n",
      "              48.8491850853\n",
      "            ],\n",
      "            [\n",
      "              2.365322113,\n",
      "              48.8442710572\n",
      "            ],\n",
      "            [\n",
      "              2.3629188538,\n",
      "              48.8400909296\n",
      "            ],\n",
      "            [\n",
      "              2.3513317108,\n",
      "              48.8363624133\n",
      "            ],\n",
      "            [\n",
      "              2.3368692398,\n",
      "              48.8393000554\n",
      "            ],\n",
      "            [\n",
      "              2.3351955414,\n",
      "              48.8398367214\n",
      "            ],\n",
      "            [\n",
      "              2.3342084885,\n",
      "              48.8402039106\n",
      "            ],\n",
      "            [\n",
      "              2.3331356049,\n",
      "              48.8405146071\n",
      "            ],\n",
      "            [\n",
      "              2.331032753,\n",
      "              48.8411359942\n",
      "            ]\n",
      "          ]\n",
      "        ]\n",
      "      }\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open('geojson-data.json', 'r') as f:\n",
    "    geojson = f.read()\n",
    "    print geojson"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "User Guide: https://github.com/keplergl/kepler.gl/blob/master/docs/keplergl-jupyter/user-guide.md\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1e37c6ad65ec4f34a611fbdd1928fb3d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "KeplerGl(height=600)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import keplergl\n",
    "map_1 = keplergl.KeplerGl(height=600)\n",
    "map_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "map_1.add_data(geojson, \"geojson\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "geojson_map.html\n"
     ]
    },
    {
     "ename": "Exception",
     "evalue": "data type incorrect expecting a dictionary mapping from data id to value, but got <type 'str'>",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mException\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-5-b5d72a09ca54>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmap_1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msave_to_html\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"geojson_map.html\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m/Users/shanhe/Uber/kepler.gl/bindings/kepler.gl-jupyter/keplergl/keplergl.py\u001b[0m in \u001b[0;36msave_to_html\u001b[0;34m(self, data, config, file_name, read_only)\u001b[0m\n\u001b[1;32m    158\u001b[0m         \u001b[0mk\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkeplergl_html\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfind\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"<body>\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    159\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 160\u001b[0;31m         \u001b[0mdata_to_add\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mNone\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0mdata_to_json\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    161\u001b[0m         \u001b[0mconfig_to_add\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconfig\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mconfig\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mNone\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    162\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/shanhe/Uber/kepler.gl/bindings/kepler.gl-jupyter/keplergl/keplergl.py\u001b[0m in \u001b[0;36mdata_to_json\u001b[0;34m(data, manager)\u001b[0m\n\u001b[1;32m     55\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     56\u001b[0m             \u001b[0;32mprint\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 57\u001b[0;31m             \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'data type incorrect expecting a dictionary mapping from data id to value, but got {}'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     58\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     59\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mException\u001b[0m: data type incorrect expecting a dictionary mapping from data id to value, but got <type 'str'>"
     ]
    }
   ],
   "source": [
    "map_1.save_to_html(file_name=\"geojson_map.html\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
